Skip to content

Commit 4a34cea

Browse files
committed
完善样板镜像功能
1 parent 7db9528 commit 4a34cea

3 files changed

Lines changed: 52 additions & 10 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ dependencies {
206206
implementation(rfg.deobf("curse.maven:ae2-extended-life-570458:6302098"))
207207
implementation(rfg.deobf("curse.maven:ae2-fluid-crafting-rework-623955:5504001"))
208208
implementation(rfg.deobf("curse.maven:mekanism-energistics-1027681:5408319"))
209+
implementation(rfg.deobf("curse.maven:nae2-884359:5380800"))
209210

210211
// GeckoLib
211212
implementation("software.bernie.geckolib:geckolib-forge-1.12.2:3.0.31")
@@ -233,7 +234,6 @@ dependencies {
233234
// Optimization
234235
implementation(rfg.deobf("curse.maven:stellarcore-1064321:5560444"))
235236
implementation(rfg.deobf("curse.maven:configanytime-870276:5212709"))
236-
implementation(rfg.deobf("curse.maven:nae2-884359:5380800"))
237237
}
238238

239239
// Publishing to a Maven repository

src/main/java/github/kasuminova/mmce/common/world/MachineComponentManager.java

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package github.kasuminova.mmce.common.world;
22

33
import com.github.bsideup.jabel.Desugar;
4+
import github.kasuminova.mmce.common.tile.MEPatternMirrorImage;
5+
import github.kasuminova.mmce.common.tile.MEPatternProvider;
46
import github.kasuminova.mmce.common.util.concurrent.ExecuteGroup;
57
import hellfirepvp.modularmachinery.common.tiles.base.TileMultiblockMachineController;
68
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
@@ -9,6 +11,8 @@
911
import net.minecraft.tileentity.TileEntity;
1012
import net.minecraft.util.math.BlockPos;
1113
import net.minecraft.world.World;
14+
import net.minecraftforge.fml.common.Loader;
15+
import net.minecraftforge.fml.common.Optional;
1216

1317
import java.util.Collections;
1418
import java.util.Map;
@@ -40,16 +44,26 @@ public void removeWorld(World world) {
4044

4145
public void checkComponentShared(TileEntity component, TileMultiblockMachineController ctrl) {
4246
World world = component.getWorld();
43-
BlockPos pos = component.getPos();
47+
BlockPos pos;
48+
TileEntity te;
49+
50+
if (Loader.isModLoaded("appliedenergistics2")){
51+
Object[] result = getResult(component, world);
52+
pos = (BlockPos) result[0];
53+
te = (TileEntity) result[1];
54+
} else {
55+
te = component;
56+
pos = component.getPos();
57+
}
4458

4559
Map<BlockPos, ComponentInfo> posComponentMap = componentMap.computeIfAbsent(world, v -> new ConcurrentHashMap<>());
4660

47-
synchronized (component) {
61+
synchronized (te) {
4862
ComponentInfo info = posComponentMap.computeIfAbsent(pos, v -> new ComponentInfo(
49-
component, pos, ReferenceSets.synchronize(new ReferenceOpenHashSet<>(Collections.singleton(ctrl)))));
63+
te, pos, ReferenceSets.synchronize(new ReferenceOpenHashSet<>(Collections.singleton(ctrl)))));
5064

51-
if (!info.areTileEntityEquals(component)) {
52-
ComponentInfo newInfo = new ComponentInfo(component, pos, ReferenceSets.synchronize(new ReferenceOpenHashSet<>(Collections.singleton(ctrl))));
65+
if (!info.areTileEntityEquals(te)) {
66+
ComponentInfo newInfo = new ComponentInfo(te, pos, ReferenceSets.synchronize(new ReferenceOpenHashSet<>(Collections.singleton(ctrl))));
5367
posComponentMap.put(pos, newInfo);
5468
return;
5569
}
@@ -73,9 +87,36 @@ public void checkComponentShared(TileEntity component, TileMultiblockMachineCont
7387
}
7488
}
7589

90+
@Optional.Method(modid = "appliedenergistics2")
91+
private static Object[] getResult(TileEntity component, World world) {
92+
BlockPos pos = component.getPos();
93+
TileEntity te = component;
94+
95+
if (component instanceof MEPatternMirrorImage mepi){
96+
if (mepi.providerPos != null){
97+
TileEntity tileEntity = world.getTileEntity(mepi.providerPos);
98+
if (tileEntity instanceof MEPatternProvider mep){
99+
te = mep;
100+
pos = mep.getPos();
101+
}
102+
}
103+
}
104+
return new Object[]{pos,te};
105+
}
106+
76107
public void removeOwner(TileEntity component, TileMultiblockMachineController ctrl) {
77108
World world = component.getWorld();
78-
BlockPos pos = component.getPos();
109+
BlockPos pos;
110+
TileEntity te;
111+
112+
if (Loader.isModLoaded("appliedenergistics2")){
113+
Object[] result = getResult(component, world);
114+
pos = (BlockPos) result[0];
115+
te = (TileEntity) result[1];
116+
} else {
117+
te = component;
118+
pos = component.getPos();
119+
}
79120

80121
Map<BlockPos, ComponentInfo> posComponentMap = componentMap.computeIfAbsent(world, v -> new ConcurrentHashMap<>());
81122

@@ -84,8 +125,8 @@ public void removeOwner(TileEntity component, TileMultiblockMachineController ct
84125
return;
85126
}
86127

87-
if (!info.areTileEntityEquals(component)) {
88-
ComponentInfo newInfo = new ComponentInfo(component, pos, new ObjectArraySet<>());
128+
if (!info.areTileEntityEquals(te)) {
129+
ComponentInfo newInfo = new ComponentInfo(te, pos, new ObjectArraySet<>());
89130
posComponentMap.put(pos, newInfo);
90131
} else {
91132
Set<TileMultiblockMachineController> owners = info.owners;

src/main/java/hellfirepvp/modularmachinery/common/crafting/MachineRecipe.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class MachineRecipe implements Comparable<MachineRecipe> {
5151

5252
protected static int counter = 0;
5353

54-
protected final boolean loadJEI;
5554
protected final int sortId;
5655
protected final String recipeFilePath;
5756
protected final ResourceLocation owningMachine, registryName;
@@ -66,6 +65,7 @@ public class MachineRecipe implements Comparable<MachineRecipe> {
6665
protected boolean parallelized;
6766
protected String threadName;
6867
protected int maxThreads;
68+
protected boolean loadJEI;
6969

7070
public MachineRecipe(String path, ResourceLocation registryName, ResourceLocation owningMachine,
7171
int tickTime, int configuredPriority, boolean voidPerTickFailure, boolean parallelized) {
@@ -125,6 +125,7 @@ public MachineRecipe(PreparedRecipe preparedRecipe) {
125125
public void mergeAdapter(final RecipeAdapterBuilder adapterBuilder) {
126126
this.parallelized = adapterBuilder.isParallelized();
127127
this.tooltipList.addAll(adapterBuilder.getTooltipList());
128+
this.loadJEI = adapterBuilder.getLoadJEI();
128129
if (!adapterBuilder.getThreadName().isEmpty()) {
129130
this.threadName = adapterBuilder.getThreadName();
130131
}

0 commit comments

Comments
 (0)