33import gregtech .api .GTValues ;
44import gregtech .api .GregTechAPI ;
55import gregtech .api .block .IHeatingCoilBlockStats ;
6- import gregtech .api .capability .GregtechDataCodes ;
76import gregtech .api .capability .IHeatingCoil ;
87import gregtech .api .capability .impl .HeatingCoilRecipeLogic ;
98import gregtech .api .metatileentity .MetaTileEntity ;
3736import net .minecraft .client .resources .I18n ;
3837import net .minecraft .init .Blocks ;
3938import net .minecraft .item .ItemStack ;
40- import net .minecraft .network .PacketBuffer ;
4139import net .minecraft .util .EnumFacing ;
4240import net .minecraft .util .ResourceLocation ;
4341import net .minecraft .util .SoundEvent ;
5149
5250import com .cleanroommc .modularui .api .drawable .IKey ;
5351import com .cleanroommc .modularui .value .sync .DoubleSyncValue ;
52+ import com .cleanroommc .modularui .value .sync .IntSyncValue ;
5453import org .jetbrains .annotations .NotNull ;
5554import org .jetbrains .annotations .Nullable ;
5655
5756import java .util .ArrayList ;
5857import java .util .Comparator ;
5958import java .util .List ;
59+ import java .util .function .Consumer ;
6060
6161import static gregtech .api .util .RelativeDirection .*;
6262
6363public class MetaTileEntityElectricBlastFurnace extends RecipeMapMultiblockController implements IHeatingCoil {
6464
65- private static final int UPDATE_TEMP = GregtechDataCodes .assignId ();
6665 private int blastFurnaceTemperature ;
6766
6867 public MetaTileEntityElectricBlastFurnace (ResourceLocation metaTileEntityId ) {
@@ -75,25 +74,6 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
7574 return new MetaTileEntityElectricBlastFurnace (metaTileEntityId );
7675 }
7776
78- @ Override
79- public void writeInitialSyncData (PacketBuffer buf ) {
80- super .writeInitialSyncData (buf );
81- buf .writeInt (blastFurnaceTemperature );
82- }
83-
84- @ Override
85- public void receiveInitialSyncData (PacketBuffer buf ) {
86- super .receiveInitialSyncData (buf );
87- this .blastFurnaceTemperature = buf .readInt ();
88- }
89-
90- @ Override
91- public void receiveCustomData (int dataId , PacketBuffer buf ) {
92- super .receiveCustomData (dataId , buf );
93- if (dataId == UPDATE_TEMP )
94- this .blastFurnaceTemperature = buf .readInt ();
95- }
96-
9777 @ Override
9878 protected void addDisplayText (List <ITextComponent > textList ) {
9979 MultiblockDisplayText .builder (textList , isStructureFormed ())
@@ -121,26 +101,30 @@ protected void addDisplayText(List<ITextComponent> textList) {
121101 @ Override
122102 protected MultiblockUIFactory createUIFactory () {
123103 DoubleSyncValue progress = new DoubleSyncValue (recipeMapWorkable ::getProgressPercent , null );
104+ IntSyncValue temp = new IntSyncValue (this ::getCurrentTemperature , null );
124105 return new MultiblockUIFactory (this )
125106 .syncValue ("progress" , progress )
107+ .syncValue ("temp" , temp )
126108 .configureDisplayText (builder -> builder
127109 .setWorkingStatus (recipeMapWorkable ::isWorkingEnabled , recipeMapWorkable ::isActive )
128110 .addEnergyUsageLine (getEnergyContainer ())
129111 .addEnergyTierLine (GTUtility .getTierByVoltage (recipeMapWorkable .getMaxVoltage ()))
130- .addCustom (this :: addHeatCapacity )
112+ .addCustom (addHeatCapacity ( temp ) )
131113 .addParallelsLine (recipeMapWorkable .getParallelLimit ())
132114 .addWorkingStatusLine ()
133115 .addProgressLine (progress ::getDoubleValue ));
134116 }
135117
136- private void addHeatCapacity (List <IKey > keyList ) {
137- if (isStructureFormed ()) {
138- var heatString = KeyUtil .number (TextFormatting .RED ,
139- getCurrentTemperature (), "K" );
118+ private Consumer <List <IKey >> addHeatCapacity (IntSyncValue temp ) {
119+ return keyList -> {
120+ if (isStructureFormed ()) {
121+ var heatString = KeyUtil .number (TextFormatting .RED ,
122+ temp ::getIntValue , "K" );
140123
141- keyList .add (KeyUtil .lang (TextFormatting .GRAY ,
142- "gregtech.multiblock.blast_furnace.max_temperature" , heatString ));
143- }
124+ keyList .add (KeyUtil .lang (TextFormatting .GRAY ,
125+ "gregtech.multiblock.blast_furnace.max_temperature" , heatString ));
126+ }
127+ };
144128 }
145129
146130 @ Override
@@ -155,7 +139,6 @@ protected void formStructure(PatternMatchContext context) {
155139 // the subtracted tier gives the starting level (exclusive) of the +100K heat bonus
156140 this .blastFurnaceTemperature += 100 *
157141 Math .max (0 , GTUtility .getFloorTierByVoltage (getEnergyContainer ().getInputVoltage ()) - GTValues .MV );
158- writeCustomData (UPDATE_TEMP , buffer -> buffer .writeInt (this .blastFurnaceTemperature ));
159142 }
160143
161144 @ Override
0 commit comments