为超级核心注册ae2连接能力
This commit is contained in:
parent
6abe36247d
commit
acae68652a
|
|
@ -8,8 +8,10 @@ import appeng.api.networking.ticking.TickRateModulation;
|
|||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.stacks.GenericStack;
|
||||
import appeng.api.stacks.KeyCounter;
|
||||
import appeng.blockentity.crafting.IMolecularAssemblerSupportedPattern;
|
||||
import appeng.util.inv.AppEngInternalInventory;
|
||||
import appeng.util.inv.CombinedInternalInventory;
|
||||
import com.extendedae_plus.ExtendedAEPlus;
|
||||
import com.extendedae_plus.init.ModBlockEntities;
|
||||
import com.glodblock.github.extendedae.common.me.CraftingMatrixThread;
|
||||
import com.glodblock.github.extendedae.common.me.CraftingThread;
|
||||
|
|
@ -73,6 +75,7 @@ public class CrafterCorePlusBlockEntity extends TileAssemblerMatrixCrafter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int usedThread() {
|
||||
int cnt = 0;
|
||||
for (var t : this.plusThreads) {
|
||||
|
|
@ -82,15 +85,17 @@ public class CrafterCorePlusBlockEntity extends TileAssemblerMatrixCrafter {
|
|||
cnt++;
|
||||
}
|
||||
}
|
||||
// 向集群汇报时仍然受原版 8 线程上限限制,避免破坏 Cluster 逻辑
|
||||
double scale = (double) TileAssemblerMatrixCrafter.MAX_THREAD / MAX_THREAD;
|
||||
int reported = (int) Math.ceil(cnt * scale);
|
||||
return Math.min(TileAssemblerMatrixCrafter.MAX_THREAD, reported);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushJob(IPatternDetails patternDetails, KeyCounter[] inputHolder) {
|
||||
for (var thread : this.plusThreads) {
|
||||
for (int i = 0; i < this.plusThreads.length; i++) {
|
||||
var thread = this.plusThreads[i];
|
||||
|
||||
if (thread.acceptJob(patternDetails, inputHolder, Direction.DOWN)) {
|
||||
this.getMainNode().ifPresent((grid, node) -> grid.getTickManager().wakeDevice(node));
|
||||
|
||||
if (this.cluster != null) {
|
||||
this.cluster.updateCrafter(this);
|
||||
}
|
||||
|
|
@ -159,7 +164,8 @@ public class CrafterCorePlusBlockEntity extends TileAssemblerMatrixCrafter {
|
|||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
var rate = TickRateModulation.SLEEP;
|
||||
for (var t : this.plusThreads) {
|
||||
for (int i = 0; i < this.plusThreads.length; i++) {
|
||||
var t = this.plusThreads[i];
|
||||
if (t.isAwake()) {
|
||||
var tr = t.tick(this.cluster.getSpeedCore(), ticksSinceLastCall);
|
||||
if (tr.ordinal() > rate.ordinal()) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ package com.extendedae_plus.init;
|
|||
import appeng.api.AECapabilities;
|
||||
import appeng.api.networking.IInWorldGridNodeHost;
|
||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||
import com.extendedae_plus.content.matrix.CrafterCorePlusBlockEntity;
|
||||
import com.extendedae_plus.content.matrix.PatternCorePlusBlockEntity;
|
||||
import com.extendedae_plus.content.matrix.SpeedCorePlusBlockEntity;
|
||||
import com.extendedae_plus.content.matrix.UploadCoreBlockEntity;
|
||||
|
||||
/**
|
||||
* 注册 AE2 能力给本模组的方块实体,确保 AE 电缆能识别并连接到我们的 In-World Grid Node。
|
||||
|
|
@ -40,6 +44,28 @@ public final class ModCapabilities {
|
|||
(be, ctx) -> (IInWorldGridNodeHost) be
|
||||
);
|
||||
|
||||
// 装配矩阵核心方块(均实现了 IInWorldGridNodeHost)
|
||||
event.registerBlockEntity(
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.ASSEMBLER_MATRIX_CRAFTER_PLUS_BE.get(),
|
||||
(be, ctx) -> (CrafterCorePlusBlockEntity) be
|
||||
);
|
||||
event.registerBlockEntity(
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.ASSEMBLER_MATRIX_PATTERN_PLUS_BE.get(),
|
||||
(be, ctx) -> (PatternCorePlusBlockEntity) be
|
||||
);
|
||||
event.registerBlockEntity(
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.ASSEMBLER_MATRIX_SPEED_PLUS_BE.get(),
|
||||
(be, ctx) -> (SpeedCorePlusBlockEntity) be
|
||||
);
|
||||
event.registerBlockEntity(
|
||||
AECapabilities.IN_WORLD_GRID_NODE_HOST,
|
||||
ModBlockEntities.UPLOAD_CORE_BE.get(),
|
||||
(be, ctx) -> (UploadCoreBlockEntity) be
|
||||
);
|
||||
|
||||
// 如果还有其他实现了 IInWorldGridNodeHost 的方块实体,也在这里一并注册
|
||||
// event.registerBlockEntity(AECapabilities.IN_WORLD_GRID_NODE_HOST, ModBlockEntities.NETWORK_PATTERN_CONTROLLER_BE.get(), (be, ctx) -> (IInWorldGridNodeHost) be);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.extendedae_plus.mixin.extendedae.common.matrix;
|
||||
|
||||
import com.extendedae_plus.content.matrix.CrafterCorePlusBlockEntity;
|
||||
import com.glodblock.github.extendedae.common.me.matrix.ClusterAssemblerMatrix;
|
||||
import com.glodblock.github.extendedae.common.tileentities.matrix.TileAssemblerMatrixCrafter;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceSet;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = ClusterAssemblerMatrix.class, remap = false)
|
||||
public class ClusterAssemblerMatrixMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ReferenceSet<TileAssemblerMatrixCrafter> availableCrafters;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ReferenceSet<TileAssemblerMatrixCrafter> busyCrafters;
|
||||
|
||||
/**
|
||||
* 重写 addCrafter 逻辑,对 CrafterCorePlusBlockEntity 使用正确的线程上限判断
|
||||
*/
|
||||
@Inject(method = "addCrafter", at = @At("HEAD"), cancellable = true)
|
||||
private void onAddCrafter(TileAssemblerMatrixCrafter crafter, CallbackInfo ci) {
|
||||
if (crafter instanceof CrafterCorePlusBlockEntity plusCrafter) {
|
||||
// 对于超级合成核心,使用32线程上限判断
|
||||
if (plusCrafter.usedThread() < CrafterCorePlusBlockEntity.MAX_THREAD) {
|
||||
this.availableCrafters.add(crafter);
|
||||
} else {
|
||||
this.busyCrafters.add(crafter);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
// 其他类型的Crafter走原版逻辑
|
||||
}
|
||||
}
|
||||
|
|
@ -54,6 +54,8 @@
|
|||
"ae2WTlib.ContainerUWirelessExPatternTerminalMixin",
|
||||
"extendedae.common.PartExPatternProviderMixin",
|
||||
"extendedae.common.TileExPatternProviderMixin",
|
||||
"extendedae.common.matrix.ClusterAssemblerMatrixMixin",
|
||||
"extendedae.common.matrix.ClusterAssemblerMatrixMixin",
|
||||
"extendedae.container.ContainerAssemblerMatrixPatternSlotTrackerMixin",
|
||||
"extendedae.container.ContainerExPatternProviderMixin",
|
||||
"extendedae.container.ContainerExPatternTerminalMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user