装配矩阵上传核心
This commit is contained in:
parent
ba22d3ae2e
commit
0090d302f1
|
|
@ -74,6 +74,14 @@ public class ExtendedAEPlus {
|
|||
ModNetwork.register();
|
||||
// 注册自定义 Curios 宿主定位器,便于将菜单宿主信息在服务端与客户端间同步
|
||||
MenuLocators.register(CuriosItemLocator.class, CuriosItemLocator::writeToPacket, CuriosItemLocator::readFromPacket);
|
||||
|
||||
// 绑定装配矩阵上传核心的方块实体类型(延迟到注册完成后)
|
||||
com.extendedae_plus.init.ModBlocks.ASSEMBLER_MATRIX_UPLOAD_CORE.get().setBlockEntity(
|
||||
com.extendedae_plus.content.matrix.UploadCoreBlockEntity.class,
|
||||
com.extendedae_plus.init.ModBlockEntities.UPLOAD_CORE_BE.get(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.extendedae_plus.content.matrix;
|
||||
|
||||
import com.glodblock.github.extendedae.common.blocks.matrix.BlockAssemblerMatrixBase;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
/**
|
||||
* ExtendedAE_Plus: 装配矩阵上传核心方块(内部功能块)。
|
||||
* 仅用于作为多方块内部的“功能块”存在;是否允许自动上传由工具类检查集群中是否存在该核心决定。
|
||||
*/
|
||||
public class UploadCoreBlock extends BlockAssemblerMatrixBase<UploadCoreBlockEntity> {
|
||||
|
||||
public UploadCoreBlock() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UploadCoreBlock(BlockBehaviour.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPresentItem() {
|
||||
// 由对应的 BlockItem 注册返回,上传核心不需要特殊的 PresentItem,可返回自身的 BlockItem
|
||||
return com.extendedae_plus.init.ModItems.ASSEMBLER_MATRIX_UPLOAD_CORE.get();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.extendedae_plus.content.matrix;
|
||||
|
||||
import com.glodblock.github.extendedae.common.me.matrix.ClusterAssemblerMatrix;
|
||||
import com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixFunction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* ExtendedAE_Plus: 装配矩阵上传核心方块实体。
|
||||
* 作为矩阵内部功能块,仅用于标记该矩阵允许被自动上传(工具类会在集群中查找此实体)。
|
||||
*/
|
||||
public class UploadCoreBlockEntity extends TileAssemblerMatrixFunction {
|
||||
|
||||
public UploadCoreBlockEntity(BlockPos pos, BlockState state) {
|
||||
super((BlockEntityType<?>) com.extendedae_plus.init.ModBlockEntities.UPLOAD_CORE_BE.get(), pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ClusterAssemblerMatrix c) {
|
||||
// 无需修改集群,仅作为存在性标记。
|
||||
// 若后续需要限制为“最多一个”,可在 ExtendedAE_Plus 工具类或事件中做校验与提示。
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.extendedae_plus.init;
|
|||
|
||||
import com.extendedae_plus.ExtendedAEPlus;
|
||||
import com.extendedae_plus.content.wireless.WirelessTransceiverBlockEntity;
|
||||
import com.extendedae_plus.content.matrix.UploadCoreBlockEntity;
|
||||
import com.extendedae_plus.content.controller.NetworkPatternControllerBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
|
@ -23,4 +24,10 @@ public final class ModBlockEntities {
|
|||
BLOCK_ENTITY_TYPES.register("network_pattern_controller",
|
||||
() -> BlockEntityType.Builder.of(NetworkPatternControllerBlockEntity::new,
|
||||
ModBlocks.NETWORK_PATTERN_CONTROLLER.get()).build(null));
|
||||
|
||||
// 装配矩阵上传核心
|
||||
public static final RegistryObject<BlockEntityType<UploadCoreBlockEntity>> UPLOAD_CORE_BE =
|
||||
BLOCK_ENTITY_TYPES.register("assembler_matrix_upload_core",
|
||||
() -> BlockEntityType.Builder.of(UploadCoreBlockEntity::new,
|
||||
ModBlocks.ASSEMBLER_MATRIX_UPLOAD_CORE.get()).build(null));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.extendedae_plus.init;
|
|||
|
||||
import com.extendedae_plus.ExtendedAEPlus;
|
||||
import com.extendedae_plus.content.wireless.WirelessTransceiverBlock;
|
||||
import com.extendedae_plus.content.matrix.UploadCoreBlock;
|
||||
import com.extendedae_plus.content.crafting.EPlusCraftingUnitType;
|
||||
import appeng.block.crafting.CraftingUnitBlock;
|
||||
import appeng.blockentity.crafting.CraftingBlockEntity;
|
||||
|
|
@ -39,6 +40,16 @@ public final class ModBlocks {
|
|||
)
|
||||
);
|
||||
|
||||
// 装配矩阵上传核心(内部功能块)
|
||||
public static final RegistryObject<UploadCoreBlock> ASSEMBLER_MATRIX_UPLOAD_CORE = BLOCKS.register(
|
||||
"assembler_matrix_upload_core",
|
||||
() -> {
|
||||
var b = new UploadCoreBlock();
|
||||
// 注意:方块实体绑定延后到 commonSetup 的 enqueueWork 中执行,避免注册阶段循环依赖
|
||||
return b;
|
||||
}
|
||||
);
|
||||
|
||||
// Crafting Accelerators (reuse MAE2 textures/models)
|
||||
public static final RegistryObject<CraftingUnitBlock> ACCELERATOR_4x = BLOCKS.register(
|
||||
"4x_crafting_accelerator",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ public final class ModItems {
|
|||
() -> new BlockItem(ModBlocks.NETWORK_PATTERN_CONTROLLER.get(), new Item.Properties())
|
||||
);
|
||||
|
||||
// 装配矩阵上传核心(方块物品)
|
||||
public static final RegistryObject<Item> ASSEMBLER_MATRIX_UPLOAD_CORE = ITEMS.register(
|
||||
"assembler_matrix_upload_core",
|
||||
() -> new BlockItem(ModBlocks.ASSEMBLER_MATRIX_UPLOAD_CORE.get(), new Item.Properties())
|
||||
);
|
||||
|
||||
// Crafting Accelerators
|
||||
public static final RegistryObject<Item> ACCELERATOR_4x = ITEMS.register(
|
||||
"4x_crafting_accelerator",
|
||||
|
|
|
|||
|
|
@ -543,7 +543,7 @@ public class ExtendedAEPatternUploadUtil {
|
|||
var tiles = grid.getMachines(com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixPattern.class);
|
||||
int idx = 0;
|
||||
for (com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixPattern tile : tiles) {
|
||||
if (tile != null && tile.isFormed() && tile.getMainNode().isActive()) {
|
||||
if (tile != null && tile.isFormed() && tile.getMainNode().isActive() && clusterHasSingleUploadCore(tile)) {
|
||||
var inv = tile.getExposedInventory();
|
||||
if (inv != null) {
|
||||
result.add(inv);
|
||||
|
|
@ -565,7 +565,7 @@ public class ExtendedAEPatternUploadUtil {
|
|||
Set<TileAssemblerMatrixBase> matrices = grid.getMachines(TileAssemblerMatrixBase.class);
|
||||
int idx = 0;
|
||||
for (TileAssemblerMatrixBase tile : matrices) {
|
||||
if (tile != null && tile.isFormed()) {
|
||||
if (tile != null && tile.isFormed() && clusterHasSingleUploadCore(tile)) {
|
||||
var capOpt = tile.getCapability(ForgeCapabilities.ITEM_HANDLER, null);
|
||||
if (capOpt != null) {
|
||||
var handler = capOpt.orElse(null);
|
||||
|
|
@ -631,6 +631,28 @@ public class ExtendedAEPatternUploadUtil {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断给定矩阵集群中是否存在且仅存在一个“装配矩阵上传核心”。
|
||||
* 传入任意属于该集群的 Tile(如 Pattern/Crafter/Frame 等)。
|
||||
*/
|
||||
private static boolean clusterHasSingleUploadCore(TileAssemblerMatrixBase any) {
|
||||
try {
|
||||
if (any == null || any.getCluster() == null) return false;
|
||||
int cores = 0;
|
||||
var it = any.getCluster().getBlockEntities();
|
||||
while (it.hasNext()) {
|
||||
var te = it.next();
|
||||
if (te instanceof com.extendedae_plus.content.matrix.UploadCoreBlockEntity) {
|
||||
cores++;
|
||||
if (cores > 1) return false; // 至多一个
|
||||
}
|
||||
}
|
||||
return cores == 1; // 恰好一个
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前菜单是否为ExtendedAE的扩展样板管理终端
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user