1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package gregtech.api.multitileentity.multiblock.base;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import gregtech.api.logic.ComplexParallelProcessingLogic;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
public abstract class ComplexParallelController<C extends ComplexParallelController<C, P>, P extends ComplexParallelProcessingLogic<P>>
extends Controller<C, P> {
protected int maxComplexParallels = 0;
protected int currentComplexParallels = 0;
public ComplexParallelController() {
isSimpleMachine = false;
}
protected void setMaxComplexParallels(int parallel, boolean stopMachine) {
if (parallel != maxComplexParallels && maxComplexParallels != 0 && stopMachine) {
stopMachine(false);
}
maxComplexParallels = parallel;
setProcessingUpdate(true);
}
@Override
protected void stopMachine(boolean powerShutDown) {
super.stopMachine(powerShutDown);
}
protected boolean hasPerfectOverclock() {
return false;
}
@Override
protected void addProgressStringToScanner(EntityPlayer player, int logLevel, ArrayList<String> list) {
P processing = getProcessingLogic();
for (int i = 0; i < maxComplexParallels; i++) {
list.add(
StatCollector.translateToLocal("GT5U.multiblock.Progress") + " "
+ (i + 1)
+ ": "
+ EnumChatFormatting.GREEN
+ GT_Utility.formatNumbers(
processing.getProgress(i) > 20 ? processing.getProgress(i) / 20 : processing.getProgress(i))
+ EnumChatFormatting.RESET
+ (processing.getProgress(i) > 20 ? " s / " : " ticks / ")
+ EnumChatFormatting.YELLOW
+ GT_Utility.formatNumbers(
processing.getDuration(i) > 20 ? processing.getDuration(i) / 20 : processing.getDuration(i))
+ EnumChatFormatting.RESET
+ (processing.getDuration(i) > 20 ? " s" : " ticks"));
}
}
@Override
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
super.getWailaNBTData(player, tile, tag, world, x, y, z);
P processing = getProcessingLogic();
tag.setInteger("maxComplexParallels", maxComplexParallels);
for (int i = 0; i < maxComplexParallels; i++) {
tag.setInteger("maxProgress" + i, processing.getDuration(i));
tag.setInteger("progress" + i, processing.getProgress(i));
}
}
@Override
public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
super.getWailaBody(itemStack, currentTip, accessor, config);
final NBTTagCompound tag = accessor.getNBTData();
maxComplexParallels = tag.getInteger("maxComplexParallels");
for (int i = 0; i < maxComplexParallels; i++) {
long maxProgress = tag.getInteger("maxProgress" + i);
long progress = tag.getInteger("progress" + i);
currentTip.add(
"Process " + (i + 1)
+ ": "
+ GT_Waila
.getMachineProgressString(maxProgress > 0 && maxProgress >= progress, maxProgress, progress));
}
}
@Override
public void setProcessingLogicPower(@Nonnull P processingLogic) {
processingLogic.setAmperageOC(true);
processingLogic.setAvailableAmperage(getPowerLogic().getMaxAmperage() / maxComplexParallels);
processingLogic.setAvailableVoltage(getPowerLogic().getVoltage() / maxComplexParallels);
}
@Override
public void updateProcessingLogic(@Nonnull P processingLogic) {
processingLogic.setMaxComplexParallel(maxComplexParallels);
}
}
|