Skip to content

Commit

Permalink
- public methods...
Browse files Browse the repository at this point in the history
- Internal changes.
  • Loading branch information
KasumiNova committed May 25, 2024
1 parent 946b217 commit cde374b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MachineController {
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
*/
@ZenMethod
static IMachineController getControllerAt(IWorld worldCT, IBlockPos posCT) {
public static IMachineController getControllerAt(IWorld worldCT, IBlockPos posCT) {
World world = CraftTweakerMC.getWorld(worldCT);
BlockPos pos = CraftTweakerMC.getBlockPos(posCT);
if (world == null || pos == null || !world.isBlockLoaded(pos)) {
Expand All @@ -40,7 +40,7 @@ static IMachineController getControllerAt(IWorld worldCT, IBlockPos posCT) {
* @return 如果无控制器则返回 null,否则返回 IMachineController 实例。
*/
@ZenMethod
static IMachineController getControllerAt(IWorld worldCT, int x, int y, int z) {
public static IMachineController getControllerAt(IWorld worldCT, int x, int y, int z) {
World world = CraftTweakerMC.getWorld(worldCT);
BlockPos pos = new BlockPos(x, y, z);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import github.kasuminova.mmce.common.util.concurrent.ExecuteGroup;
import hellfirepvp.modularmachinery.common.tiles.base.TileMultiblockMachineController;
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -43,10 +44,10 @@ public void checkComponentShared(TileEntity component, TileMultiblockMachineCont
Map<BlockPos, ComponentInfo> posComponentMap = componentMap.computeIfAbsent(world, v -> new ConcurrentHashMap<>());

ComponentInfo info = posComponentMap.computeIfAbsent(pos, v -> new ComponentInfo(
component, pos, new ObjectArraySet<>(Collections.singleton(ctrl))));
component, pos, new ReferenceOpenHashSet<>(Collections.singleton(ctrl))));

if (!info.areTileEntityEquals(component)) {
ComponentInfo newInfo = new ComponentInfo(component, pos, new ObjectArraySet<>(Collections.singleton(ctrl)));
ComponentInfo newInfo = new ComponentInfo(component, pos, new ReferenceOpenHashSet<>(Collections.singleton(ctrl)));
posComponentMap.put(pos, newInfo);
return;
}
Expand All @@ -62,20 +63,13 @@ public void checkComponentShared(TileEntity component, TileMultiblockMachineCont
return;
}

long groupId = -1;
for (final TileMultiblockMachineController owner : owners) {
if (owner.getExecuteGroupId() != -1) {
groupId = owner.getExecuteGroupId();
}
}

if (groupId == -1) {
groupId = ExecuteGroup.newGroupId();
}
long groupId = owners.stream()
.filter(owner -> owner.getExecuteGroupId() != -1)
.findFirst()
.map(TileMultiblockMachineController::getExecuteGroupId)
.orElse(ExecuteGroup.newGroupId());

for (final TileMultiblockMachineController owner : owners) {
owner.setExecuteGroupId(groupId);
}
owners.forEach(owner -> owner.setExecuteGroupId(groupId));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TextFormatting.AQUA, formatCPUUsage(machine.getTimeRecorder().usedTimeAvg()),
TextFormatting.AQUA, formatRecipeSearchUsage(machine.getTimeRecorder().recipeSearchUsedTimeAvg())));
TileMultiblockMachineController.WorkMode workMode = machine.getWorkMode();
long groupId = machine.getExecuteGroupId();
if (workMode == TileMultiblockMachineController.WorkMode.ASYNC && groupId != 0) {
if (workMode == TileMultiblockMachineController.WorkMode.ASYNC && groupId != -1) {
perfBox.text(String.format("%sWorkMode: %s (GroupID: %s)", TextFormatting.AQUA, workMode.getDisplayName(), groupId));
} else {
perfBox.text(String.format("%sWorkMode: %s", TextFormatting.AQUA, workMode.getDisplayName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ protected void checkAllPatterns() {

protected void updateComponents() {
if (this.foundMachine == null || this.foundPattern == null || this.controllerRotation == null || this.foundReplacements == null) {
this.foundComponents.forEach((te, component) -> MachineComponentManager.INSTANCE.removeOwner(te, this));
this.foundComponents.clear();
this.foundModifiers.clear();
this.foundSmartInterfaces.clear();
Expand All @@ -684,6 +685,7 @@ protected void updateComponents() {

this.foundUpgrades.clear();
this.foundUpgradeBuses.clear();
this.foundComponents.forEach((te, component) -> MachineComponentManager.INSTANCE.removeOwner(te, this));
this.foundComponents.clear();
this.foundSmartInterfaces.clear();
this.foundParallelControllers.clear();
Expand Down

0 comments on commit cde374b

Please sign in to comment.