Skip to content

Commit 82732d4

Browse files
author
Circulate233
committed
可能修复了生命萃取祭坛不能正常的工作的问题
1 parent 1ddb3f8 commit 82732d4

5 files changed

Lines changed: 112 additions & 93 deletions

File tree

src/main/java/github/kasuminova/novaeng/common/hypernet/old/NetNodeImpl.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,30 @@ public NetNodeImpl(final TileMultiblockMachineController owner) {
3131
@Override
3232
public void onMachineTick() {
3333
super.onMachineTick();
34-
if (isWorking()) {
35-
if (owner.getTicksExisted() % 10 == 0) {
34+
if (this.isWorking()) {
35+
if (this.owner.getTicksExisted() % 10 == 0) {
3636
double total = 0;
37-
for (final double value : recipeConsumers.values()) {
37+
for (final double value : this.recipeConsumers.values()) {
3838
total += value;
3939
}
40-
computationPointConsumption = total;
41-
recipeConsumers.clear();
40+
this.computationPointConsumption = total;
41+
this.recipeConsumers.clear();
4242
}
4343
} else {
44-
computationPointConsumption = 0;
44+
this.computationPointConsumption = 0;
4545
}
4646
}
4747

4848
@ZenMethod
4949
public void checkComputationPoint(final RecipeCheckEvent event,
5050
final double pointRequired,
5151
final ResearchCognitionData... researchRequired) {
52-
if (centerPos == null || center == null) {
52+
if (this.centerPos == null || this.center == null) {
5353
event.setFailed("novaeng.hypernet.prrocessor.link.false");
5454
return;
5555
}
5656

57-
double generation = center.getComputationPointGeneration() - center.getComputationPointConsumption();
57+
double generation = this.center.getComputationPointGeneration() - this.center.getComputationPointConsumption();
5858
if (generation < pointRequired) {
5959
event.setFailed("算力不足!预期:"
6060
+ NovaEngUtils.formatFLOPS(pointRequired) + ",当前:"
@@ -72,12 +72,12 @@ public void checkComputationPoint(final RecipeCheckEvent event,
7272
@ZenMethod
7373
public void checkResearch(final RecipeCheckEvent event,
7474
final ResearchCognitionData... researchRequired) {
75-
if (centerPos == null || center == null) {
75+
if (this.centerPos == null || this.center == null) {
7676
event.setFailed("novaeng.hypernet.prrocessor.link.false");
7777
return;
7878
}
7979

80-
Collection<Database> nodes = center.getNode(Database.class);
80+
Collection<Database> nodes = this.center.getNode(Database.class);
8181
if (nodes.isEmpty()) {
8282
event.setFailed("计算网络中未找到数据库!");
8383
return;
@@ -92,26 +92,26 @@ public void checkResearch(final RecipeCheckEvent event,
9292
}
9393

9494
public void onRecipeStart(final RecipeStartEvent event, final double computation) {
95-
recipeConsumers.put(event.getRecipeThread(), computation * event.getActiveRecipe().getParallelism());
95+
this.recipeConsumers.put(event.getRecipeThread(), computation * event.getActiveRecipe().getParallelism());
9696
}
9797

9898
public void onRecipeStart(final FactoryRecipeStartEvent event, final double computation) {
99-
recipeConsumers.put(event.getRecipeThread(), computation * event.getActiveRecipe().getParallelism());
99+
this.recipeConsumers.put(event.getRecipeThread(), computation * event.getActiveRecipe().getParallelism());
100100
}
101101

102102
public void onRecipePreTick(final RecipeTickEvent event, final double computation, final boolean triggerFailure) {
103-
if (centerPos == null) {
103+
if (this.centerPos == null) {
104104
event.setFailed(true, "novaeng.hypernet.prrocessor.link.false");
105105
return;
106106
}
107-
if (center == null) {
107+
if (this.center == null) {
108108
event.preventProgressing("novaeng.hypernet.prrocessor.link.false");
109109
return;
110110
}
111111
double required = computation * event.getActiveRecipe().getParallelism();
112-
recipeConsumers.put(event.getRecipeThread(), required);
112+
this.recipeConsumers.put(event.getRecipeThread(), required);
113113

114-
if (!center.consumeComputationPoint(required)) {
114+
if (!this.center.consumeComputationPoint(required)) {
115115
String failureMessage = "算力不足!预期需求:" +
116116
NovaEngUtils.formatFLOPS(required);
117117

@@ -124,18 +124,18 @@ public void onRecipePreTick(final RecipeTickEvent event, final double computatio
124124
}
125125

126126
public void onRecipePreTick(final FactoryRecipeTickEvent event, final double computation, final boolean triggerFailure) {
127-
if (centerPos == null) {
127+
if (this.centerPos == null) {
128128
event.setFailed(true, "novaeng.hypernet.prrocessor.link.false");
129129
return;
130130
}
131-
if (center == null) {
131+
if (this.center == null) {
132132
event.preventProgressing("novaeng.hypernet.prrocessor.link.false");
133133
return;
134134
}
135135
double required = computation * event.getActiveRecipe().getParallelism();
136-
recipeConsumers.put(event.getRecipeThread(), required);
136+
this.recipeConsumers.put(event.getRecipeThread(), required);
137137

138-
if (!center.consumeComputationPoint(required)) {
138+
if (!this.center.consumeComputationPoint(required)) {
139139
String failureMessage = "算力不足!预期需求:" +
140140
NovaEngUtils.formatFLOPS(required);
141141

@@ -148,7 +148,7 @@ public void onRecipePreTick(final FactoryRecipeTickEvent event, final double com
148148
}
149149

150150
public void onRecipeFinished(final RecipeThread thread) {
151-
recipeConsumers.removeDouble(thread);
151+
this.recipeConsumers.removeDouble(thread);
152152
}
153153

154154
@Override
@@ -160,12 +160,12 @@ public void readNBT(final NBTTagCompound customData) {
160160
@Override
161161
public void writeNBT() {
162162
super.writeNBT();
163-
NBTTagCompound tag = owner.getCustomDataTag();
164-
tag.setDouble("c", computationPointConsumption);
163+
NBTTagCompound tag = this.owner.getCustomDataTag();
164+
tag.setDouble("c", this.computationPointConsumption);
165165
}
166166

167167
@Override
168168
public double getComputationPointConsumption() {
169-
return computationPointConsumption;
169+
return this.computationPointConsumption;
170170
}
171171
}

src/main/java/github/kasuminova/novaeng/common/machine/LifeExtractsAltar.kt

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package github.kasuminova.novaeng.common.machine
22

33
import crafttweaker.CraftTweakerAPI.itemUtils
44
import github.kasuminova.mmce.common.event.client.ControllerGUIRenderEvent
5+
import github.kasuminova.mmce.common.event.recipe.RecipeEvent
56
import github.kasuminova.novaeng.NovaEngineeringCore
67
import github.kasuminova.novaeng.common.machine.MMAltar.addBlood
7-
import github.kasuminova.novaeng.common.machine.MMAltar.checkAlter
8+
import github.kasuminova.novaeng.common.machine.MMAltar.checkRitualWellOfSuffering
89
import github.kasuminova.novaeng.common.machine.MMAltar.getAltar
910
import github.kasuminova.novaeng.common.util.Functions
1011
import github.kasuminova.novaeng.common.util.RecipePrimerEx.setLore
@@ -45,53 +46,51 @@ object LifeExtractsAltar : MachineSpecial {
4546
return@setNBTChecker true
4647
} else return@setNBTChecker false
4748
}
48-
.addPreCheckHandler {
49-
val ctrl = it.controller
50-
val data = ctrl.customDataTag
51-
val world = ctrl.world
52-
val mmpos = BlockPos.PooledMutableBlockPos.retain(
53-
data.getInteger("x"),
54-
data.getInteger("y"),
55-
data.getInteger("z")
56-
)
57-
val mm_altarctrl =
58-
world.getTileEntity(mmpos) as? TileMultiblockMachineController
59-
mmpos.release()
60-
if (!world.isRemote) {
61-
if (mm_altarctrl == null) {
62-
it.setFailed("novaeng.life_extracts_altar.failed.0")
63-
return@addPreCheckHandler
64-
} else {
65-
val altar = mm_altarctrl.getAltar()
66-
val nbt = mm_altarctrl.customDataTag
49+
.addPostCheckHandler {
50+
val mm_altarctrl = getAltarCtrl(it)
51+
if (mm_altarctrl == null) {
52+
it.setFailed("novaeng.life_extracts_altar.failed.0")
53+
return@addPostCheckHandler
54+
} else if (!mm_altarctrl.world.isRemote) {
55+
val altar = mm_altarctrl.getAltar()
56+
val nbt = mm_altarctrl.customDataTag
6757

68-
if (altar == null) {
69-
it.setFailed("novaeng.life_extracts_altar.failed.1")
70-
return@addPreCheckHandler
71-
}
58+
if (altar == null) {
59+
it.setFailed("novaeng.life_extracts_altar.failed.1")
60+
return@addPostCheckHandler
61+
}
7262

73-
if (!checkAlter(nbt, ctrl)) {
74-
it.setFailed("novaeng.life_extracts_altar.failed.2")
75-
}
63+
if (!checkRitualWellOfSuffering(nbt, mm_altarctrl)) {
64+
it.setFailed("novaeng.life_extracts_altar.failed.2")
7665
}
7766
}
7867
}
7968
.addStartHandler {
8069
it.controller.customDataTag.setBoolean("mode", true)
8170
}
71+
.addPreTickHandler {
72+
if (it.activeRecipe.tick != 0) return@addPreTickHandler
73+
74+
val mm_altarctrl = getAltarCtrl(it)
75+
if (mm_altarctrl == null) {
76+
it.setFailed(true, "novaeng.life_extracts_altar.failed.0")
77+
return@addPreTickHandler
78+
} else if (!mm_altarctrl.world.isRemote) {
79+
val altar = mm_altarctrl.getAltar()
80+
val nbt = mm_altarctrl.customDataTag
81+
82+
if (altar == null) {
83+
it.setFailed(true, "novaeng.life_extracts_altar.failed.1")
84+
return@addPreTickHandler
85+
}
86+
87+
if (!checkRitualWellOfSuffering(nbt, mm_altarctrl)) {
88+
it.setFailed(true, "novaeng.life_extracts_altar.failed.2")
89+
}
90+
}
91+
}
8292
.addFinishHandler {
83-
val ctrl = it.controller
84-
val data = ctrl.customDataTag
85-
val world = ctrl.world
86-
val mmpos = BlockPos.PooledMutableBlockPos.retain(
87-
data.getInteger("x"),
88-
data.getInteger("y"),
89-
data.getInteger("z")
90-
)
91-
val mm_altarctrl =
92-
world.getTileEntity(mmpos) as? TileMultiblockMachineController
93-
mmpos.release()
94-
mm_altarctrl?.let { mmctrl ->
93+
getAltarCtrl(it)?.let { mmctrl ->
9594
mmctrl.getAltar()
9695
.addBlood(SINGLE_VALUE + (SINGLE_VALUE / 10) * mmctrl.customDataTag.getShort("sacrifice"))
9796
}
@@ -107,6 +106,21 @@ object LifeExtractsAltar : MachineSpecial {
107106
if (NovaEngineeringCore.proxy.isClient) clientInit(machine)
108107
}
109108

109+
private fun getAltarCtrl(event: RecipeEvent): TileMultiblockMachineController? {
110+
val ctrl = event.controller
111+
val data = ctrl.customDataTag
112+
val world = ctrl.world
113+
val mmpos = BlockPos.PooledMutableBlockPos.retain(
114+
data.getInteger("x"),
115+
data.getInteger("y"),
116+
data.getInteger("z")
117+
)
118+
val mm_altarctrl =
119+
world.getTileEntity(mmpos) as? TileMultiblockMachineController
120+
mmpos.release()
121+
return mm_altarctrl
122+
}
123+
110124
@SideOnly(Side.CLIENT)
111125
private fun clientInit(machine: DynamicMachine) {
112126
machine.addMachineEventHandler(ControllerGUIRenderEvent::class.java) {

src/main/java/github/kasuminova/novaeng/common/machine/MMAltar.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ object MMAltar : MachineSpecial {
355355
val now = altar.getNowBlood()
356356
val max = altar.getMaxBlood()
357357

358-
val check = checkAlter(nbt, ctrl)
358+
val check = checkRitualWellOfSuffering(nbt, ctrl)
359359

360360
val info = asList(
361361
getText("gui.mm_altar.tooltip.0", now, max),
@@ -372,7 +372,7 @@ object MMAltar : MachineSpecial {
372372
}
373373
}
374374

375-
fun checkAlter(
375+
fun checkRitualWellOfSuffering(
376376
nbt: NBTTagCompound,
377377
ctrl: TileMultiblockMachineController
378378
): Boolean {

src/main/java/github/kasuminova/novaeng/common/machine/drills/Drill.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ abstract class Drill : MachineSpecial {
144144
}
145145
}
146146

147-
private fun getCcrystalOutput(ctrl: TileMultiblockMachineController): IItemStack {
147+
private fun getCrystalOutput(ctrl: TileMultiblockMachineController): IItemStack {
148148
val data = ctrl.customDataTag
149149
val world = ctrl.getWorld()
150150
val research_progress = data.getByte("research_progress")
@@ -375,7 +375,7 @@ abstract class Drill : MachineSpecial {
375375
.requireComputationPoint(1.5f)
376376
.addOutput(stone)
377377
.addItemModifier { ctrl, _ ->
378-
getCcrystalOutput(ctrl.controller)
378+
getCrystalOutput(ctrl.controller)
379379
}
380380
.setChance(0.1f)
381381
.setParallelized(false)
@@ -398,7 +398,7 @@ abstract class Drill : MachineSpecial {
398398
.requireComputationPoint(1.5f)
399399
.addOutput(stone)
400400
.addItemModifier { ctrl, _ ->
401-
getCcrystalOutput(ctrl.controller)
401+
getCrystalOutput(ctrl.controller)
402402
}.setChance(0.1f)
403403
.setParallelized(true)
404404
.setThreadName(threadName)
@@ -429,7 +429,7 @@ abstract class Drill : MachineSpecial {
429429
.requireComputationPoint(3f)
430430
.addOutput(stone)
431431
.addItemModifier { ctrl, _ ->
432-
getCcrystalOutput(ctrl.controller)
432+
getCrystalOutput(ctrl.controller)
433433
}.setChance(0.035f)
434434
.setMaxThreads(1)
435435
.setParallelized(false)
@@ -454,7 +454,7 @@ abstract class Drill : MachineSpecial {
454454
.requireComputationPoint(3f)
455455
.addOutput(stone)
456456
.addItemModifier { ctrl, _ ->
457-
getCcrystalOutput(ctrl.controller)
457+
getCrystalOutput(ctrl.controller)
458458
}
459459
.setChance(0.04f)
460460
.setMaxThreads(1)

0 commit comments

Comments
 (0)