package com.choonster.testmod3.client.gui;

import com.choonster.testmod3.Logger;
import com.choonster.testmod3.TestMod3;
import com.choonster.testmod3.command.SurvivalCommandBlockLogic;
import com.choonster.testmod3.network.MessageSurvivalCommandBlockSaveChanges;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiCommandBlock;
import net.minecraft.client.gui.GuiTextField;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.io.IOException;
import java.lang.reflect.Field;

@SideOnly(Side.CLIENT)
public class GuiSurvivalCommandBlock extends GuiCommandBlock {
	private static final Field COMMAND_TEXT_FIELD = ReflectionHelper.findField(GuiCommandBlock.class, "commandTextField", "field_146485_f");

	private final SurvivalCommandBlockLogic survivalCommandBlockLogic;

	public GuiSurvivalCommandBlock(SurvivalCommandBlockLogic survivalCommandBlockLogic) {
		super(survivalCommandBlockLogic);
		this.survivalCommandBlockLogic = survivalCommandBlockLogic;
	}

	@Override
	protected void actionPerformed(GuiButton button) throws IOException {
		if (button.enabled && button.id == 0) {
			try {
				GuiTextField commandTextField = ((GuiTextField) COMMAND_TEXT_FIELD.get(this));
				TestMod3.network.sendToServer(new MessageSurvivalCommandBlockSaveChanges(survivalCommandBlockLogic, commandTextField.getText()));
			} catch (IllegalAccessException e) {
				Logger.error(e, "Couldn't set survival command block");
			}

			if (!this.survivalCommandBlockLogic.shouldTrackOutput()) {
				this.survivalCommandBlockLogic.setLastOutput(null);
			}

			this.mc.displayGuiScreen(null);
		} else {
			super.actionPerformed(button);
		}
	}
}

@@ -1267,17 +1267,16 @@
 Field = 
-(
 (GuiText
@@ -1310,17 +1310,16 @@
 et(this)
-)
 ;%0A%09%09%09%09Te

Remove unnecessary parentheses