Skip to content

Commit 38394fe

Browse files
committed
Resolve review
1 parent 071b4ea commit 38394fe

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchFluid.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import net.minecraft.client.resources.I18n;
2121
import net.minecraft.item.ItemStack;
2222
import net.minecraft.nbt.NBTTagCompound;
23+
import net.minecraft.network.PacketBuffer;
2324
import net.minecraft.util.EnumFacing;
2425
import net.minecraft.util.ResourceLocation;
2526
import net.minecraft.world.World;
@@ -35,7 +36,6 @@
3536
import com.cleanroommc.modularui.api.widget.IWidget;
3637
import com.cleanroommc.modularui.factory.PosGuiData;
3738
import com.cleanroommc.modularui.screen.ModularPanel;
38-
import com.cleanroommc.modularui.value.BoolValue;
3939
import com.cleanroommc.modularui.value.sync.BooleanSyncValue;
4040
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
4141
import 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
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityPassthroughHatchItem.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.minecraft.client.resources.I18n;
1919
import net.minecraft.item.ItemStack;
2020
import net.minecraft.nbt.NBTTagCompound;
21+
import net.minecraft.network.PacketBuffer;
2122
import net.minecraft.util.EnumFacing;
2223
import net.minecraft.util.ResourceLocation;
2324
import net.minecraft.world.World;
@@ -34,7 +35,6 @@
3435
import com.cleanroommc.modularui.api.widget.IWidget;
3536
import com.cleanroommc.modularui.factory.PosGuiData;
3637
import com.cleanroommc.modularui.screen.ModularPanel;
37-
import com.cleanroommc.modularui.value.BoolValue;
3838
import com.cleanroommc.modularui.value.sync.BooleanSyncValue;
3939
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
4040
import com.cleanroommc.modularui.value.sync.SyncHandlers;
@@ -160,9 +160,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
160160
}
161161

162162
BooleanSyncValue workingStateValue = new BooleanSyncValue(() -> workingEnabled, val -> workingEnabled = val);
163-
guiSyncManager.syncValue("working_state", workingStateValue);
164-
165-
// TODO: Change the position of the name when it's standardized.
166163
return GTGuis.createPanel(this, backgroundWidth, backgroundHeight)
167164
.child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5))
168165
.child(SlotGroupWidget.playerInventory().left(7).bottom(7))
@@ -174,8 +171,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
174171
.matrix(widgets))
175172
.child(new ToggleButton()
176173
.top(18 * 4).left(18 * 8 + 7)
177-
.value(new BoolValue.Dynamic(workingStateValue::getBoolValue,
178-
workingStateValue::setBoolValue))
174+
.value(workingStateValue)
179175
.overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT)
180176
.tooltipBuilder(t -> t.setAutoUpdate(true)
181177
.addLine(workingStateValue.getBoolValue() ?
@@ -198,8 +194,6 @@ public void readFromNBT(NBTTagCompound tag) {
198194
// Passthrough hatches before this change won't have WorkingEnabled at all, so we need to check if it exists
199195
if (tag.hasKey("WorkingEnabled")) {
200196
this.workingEnabled = tag.getBoolean("WorkingEnabled");
201-
} else {
202-
this.workingEnabled = true;
203197
}
204198
}
205199

@@ -250,4 +244,18 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
250244
}
251245
return super.getCapability(capability, side);
252246
}
247+
248+
@Override
249+
public void writeInitialSyncData(PacketBuffer buf) {
250+
super.writeInitialSyncData(buf);
251+
252+
buf.writeBoolean(workingEnabled);
253+
}
254+
255+
@Override
256+
public void receiveInitialSyncData(PacketBuffer buf) {
257+
super.receiveInitialSyncData(buf);
258+
259+
this.workingEnabled = buf.readBoolean();
260+
}
253261
}

0 commit comments

Comments
 (0)