2525
2626import aztech .modern_industrialization .MIBlock ;
2727import aztech .modern_industrialization .MIText ;
28+ import aztech .modern_industrialization .blocks .structure .StructureMemberMode ;
2829import aztech .modern_industrialization .blocks .structure .StructureMultiblockMemberBlockEntity ;
2930import aztech .modern_industrialization .machines .models .MachineCasing ;
3031import aztech .modern_industrialization .machines .multiblocks .HatchFlags ;
3132import aztech .modern_industrialization .machines .multiblocks .structure .StructureMultiblockInputFormatters ;
3233import aztech .modern_industrialization .machines .multiblocks .structure .member .StructureMemberTest ;
3334import aztech .modern_industrialization .network .structure .StructureUpdateMemberPacket ;
35+ import com .google .common .collect .ImmutableList ;
3436import com .mojang .blaze3d .platform .InputConstants ;
3537import java .util .List ;
3638import java .util .Optional ;
3739import net .minecraft .client .Minecraft ;
3840import net .minecraft .client .gui .GuiGraphics ;
3941import net .minecraft .client .gui .components .Button ;
42+ import net .minecraft .client .gui .components .CycleButton ;
4043import net .minecraft .client .gui .components .EditBox ;
4144import net .minecraft .client .gui .screens .Screen ;
4245import net .minecraft .network .chat .CommonComponents ;
@@ -48,10 +51,13 @@ public class StructureMultiblockMemberEditScreen extends Screen {
4851 private static final int VALID_TEXT_COLOR = 0xE0E0E0 ;
4952 private static final int INVALID_TEXT_COLOR = 0xE07272 ;
5053
54+ private static final ImmutableList <StructureMemberMode > ALL_MODES = ImmutableList .copyOf (StructureMemberMode .values ());
55+
5156 private final StructureMultiblockMemberBlockEntity member ;
5257
5358 private Button doneButton ;
5459 private Button cancelButton ;
60+ private CycleButton <StructureMemberMode > modeButton ;
5561
5662 private EditBox previewBox ;
5763 private EditBox membersBox ;
@@ -80,6 +86,22 @@ private Optional<HatchFlags> getHatchFlags() {
8086 return Optional .ofNullable (StructureMultiblockInputFormatters .hatchFlags (flagsBox .getValue ()));
8187 }
8288
89+ private void updateMode (StructureMemberMode mode ) {
90+ this .sendToServer ();
91+
92+ casingBox .visible = false ;
93+ flagsBox .visible = false ;
94+
95+ switch (mode ) {
96+ case HATCH -> {
97+ casingBox .visible = true ;
98+ flagsBox .visible = true ;
99+ }
100+ case SIMPLE -> {
101+ }
102+ }
103+ }
104+
83105 private void updatePreview () {
84106 boolean validPreview = previewBox .getValue ().isEmpty () || this .getPreview ().isPresent ();
85107 previewBox .setTextColor (validPreview ? VALID_TEXT_COLOR : INVALID_TEXT_COLOR );
@@ -101,6 +123,7 @@ private void updateFlags() {
101123 }
102124
103125 private void updateAll () {
126+ this .updateMode (member .getMode ());
104127 this .updatePreview ();
105128 this .updateMembers ();
106129 this .updateCasing ();
@@ -115,6 +138,7 @@ private void done() {
115138 private void sendToServer () {
116139 new StructureUpdateMemberPacket (
117140 member .getBlockPos (),
141+ modeButton .getValue (),
118142 previewBox .getValue (),
119143 membersBox .getValue (),
120144 casingBox .getValue (),
@@ -131,20 +155,25 @@ protected void init() {
131155 doneButton = Button .builder (CommonComponents .GUI_DONE , button -> this .done ()).bounds (width / 2 - 4 - 150 , 210 , 150 , 20 ).build ());
132156 this .addRenderableWidget (
133157 cancelButton = Button .builder (CommonComponents .GUI_CANCEL , button -> this .cancel ()).bounds (width / 2 + 4 , 210 , 150 , 20 ).build ());
158+ this .addRenderableWidget (modeButton = CycleButton .builder (StructureMemberMode ::text )
159+ .withValues (ALL_MODES , ALL_MODES )
160+ .displayOnlyValue ()
161+ .withInitialValue (member .getMode ())
162+ .create (width / 2 - 4 - 150 , 185 , 50 , 20 , Component .literal ("MODE" ), (button , mode ) -> this .updateMode (mode )));
134163
135- previewBox = new EditBox (font , width / 2 - 152 , 50 , 304 , 20 , MIText .StructureMultiblockMemberPreview .text ());
164+ previewBox = new EditBox (font , width / 2 - 152 , 20 , 304 , 20 , MIText .StructureMultiblockMemberPreview .text ());
136165 previewBox .setMaxLength (Short .MAX_VALUE );
137166 previewBox .setValue (member .getInputPreview ());
138167 previewBox .setResponder (text -> this .updatePreview ());
139168 this .addRenderableWidget (previewBox );
140169
141- membersBox = new EditBox (font , width / 2 - 152 , 90 , 304 , 20 , MIText .StructureMultiblockMemberMembers .text ());
170+ membersBox = new EditBox (font , width / 2 - 152 , 60 , 304 , 20 , MIText .StructureMultiblockMemberMembers .text ());
142171 membersBox .setMaxLength (Short .MAX_VALUE );
143172 membersBox .setValue (member .getInputMembers ());
144173 membersBox .setResponder (text -> this .updateMembers ());
145174 this .addRenderableWidget (membersBox );
146175
147- casingBox = new EditBox (font , width / 2 - 152 , 130 , 304 , 20 , MIText .StructureMultiblockHatchCasing .text ()) {
176+ casingBox = new EditBox (font , width / 2 - 152 , 100 , 304 , 20 , MIText .StructureMultiblockHatchCasing .text ()) {
148177 @ Override
149178 public boolean charTyped (char codePoint , int modifiers ) {
150179 return ResourceLocation .isAllowedInResourceLocation (codePoint ) && super .charTyped (codePoint , modifiers );
@@ -155,7 +184,7 @@ public boolean charTyped(char codePoint, int modifiers) {
155184 casingBox .setResponder (text -> this .updateCasing ());
156185 this .addRenderableWidget (casingBox );
157186
158- flagsBox = new EditBox (font , width / 2 - 152 , 170 , 304 , 20 , MIText .StructureMultiblockHatchFlags .text ()) {
187+ flagsBox = new EditBox (font , width / 2 - 152 , 140 , 304 , 20 , MIText .StructureMultiblockHatchFlags .text ()) {
159188 @ Override
160189 public boolean charTyped (char codePoint , int modifiers ) {
161190 return (Character .isDigit (codePoint ) || Character .isAlphabetic (codePoint ) || codePoint == ';' || codePoint == '_' )
@@ -174,15 +203,17 @@ public boolean charTyped(char codePoint, int modifiers) {
174203 public void render (GuiGraphics graphics , int mouseX , int mouseY , float partialTick ) {
175204 super .render (graphics , mouseX , mouseY , partialTick );
176205
177- graphics .drawCenteredString (font , title , width / 2 , 20 , 0xFFFFFF );
206+ graphics .drawString (font , MIText . StructureMultiblockMemberPreview . text () , width / 2 - 152 , 10 , 0xA0A0A0 );
178207
179- graphics .drawString (font , MIText .StructureMultiblockMemberPreview .text (), width / 2 - 152 , 40 , 0xA0A0A0 );
208+ graphics .drawString (font , MIText .StructureMultiblockMemberMembers .text (), width / 2 - 152 , 50 , 0xA0A0A0 );
180209
181- graphics .drawString (font , MIText .StructureMultiblockMemberMembers .text (), width / 2 - 152 , 80 , 0xA0A0A0 );
210+ if (casingBox .visible )
211+ graphics .drawString (font , MIText .StructureMultiblockHatchCasing .text (), width / 2 - 152 , 90 , 0xA0A0A0 );
182212
183- graphics .drawString (font , MIText .StructureMultiblockHatchCasing .text (), width / 2 - 152 , 120 , 0xA0A0A0 );
213+ if (flagsBox .visible )
214+ graphics .drawString (font , MIText .StructureMultiblockHatchFlags .text (), width / 2 - 152 , 130 , 0xA0A0A0 );
184215
185- graphics .drawString (font , MIText . StructureMultiblockHatchFlags . text (), width / 2 - 152 , 160 , 0xA0A0A0 );
216+ graphics .drawString (font , modeButton . getValue (). textInfo (), width / 2 - 4 - 150 , 175 , 0xA0A0A0 );
186217 }
187218
188219 @ Override
0 commit comments