2020import net .minecraft .client .resources .I18n ;
2121import net .minecraft .item .ItemStack ;
2222import net .minecraft .nbt .NBTTagCompound ;
23+ import net .minecraft .network .PacketBuffer ;
2324import net .minecraft .util .EnumFacing ;
2425import net .minecraft .util .ResourceLocation ;
2526import net .minecraft .world .World ;
3536import com .cleanroommc .modularui .api .widget .IWidget ;
3637import com .cleanroommc .modularui .factory .PosGuiData ;
3738import com .cleanroommc .modularui .screen .ModularPanel ;
38- import com .cleanroommc .modularui .value .BoolValue ;
3939import com .cleanroommc .modularui .value .sync .BooleanSyncValue ;
4040import com .cleanroommc .modularui .value .sync .PanelSyncManager ;
4141import com .cleanroommc .modularui .widgets .SlotGroupWidget ;
@@ -153,9 +153,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
153153 }
154154
155155 BooleanSyncValue workingStateValue = new BooleanSyncValue (() -> workingEnabled , val -> workingEnabled = val );
156- guiSyncManager .syncValue ("working_state" , workingStateValue );
157-
158- // TODO: Change the position of the name when it's standardized.
159156 return GTGuis .createPanel (this , backgroundWidth , backgroundHeight )
160157 .child (IKey .lang (getMetaFullName ()).asWidget ().pos (5 , 5 ))
161158 .child (SlotGroupWidget .playerInventory ().left (7 ).bottom (7 ))
@@ -167,8 +164,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
167164 .matrix (widgets ))
168165 .child (new ToggleButton ()
169166 .top (18 * 2 ).left (18 * 8 + 7 )
170- .value (new BoolValue .Dynamic (workingStateValue ::getBoolValue ,
171- workingStateValue ::setBoolValue ))
167+ .value (workingStateValue )
172168 .overlay (GTGuiTextures .BUTTON_FLUID_OUTPUT )
173169 .tooltipBuilder (t -> t .setAutoUpdate (true )
174170 .addLine (workingStateValue .getBoolValue () ?
@@ -191,8 +187,6 @@ public void readFromNBT(NBTTagCompound tag) {
191187 // Passthrough hatches before this change won't have WorkingEnabled at all, so we need to check if it exists
192188 if (tag .hasKey ("WorkingEnabled" )) {
193189 this .workingEnabled = tag .getBoolean ("WorkingEnabled" );
194- } else {
195- this .workingEnabled = true ;
196190 }
197191 }
198192
@@ -238,4 +232,18 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
238232 }
239233 return super .getCapability (capability , side );
240234 }
235+
236+ @ Override
237+ public void writeInitialSyncData (PacketBuffer buf ) {
238+ super .writeInitialSyncData (buf );
239+
240+ buf .writeBoolean (workingEnabled );
241+ }
242+
243+ @ Override
244+ public void receiveInitialSyncData (PacketBuffer buf ) {
245+ super .receiveInitialSyncData (buf );
246+
247+ this .workingEnabled = buf .readBoolean ();
248+ }
241249}
0 commit comments