Exemplo n.º 1
0
 private boolean validName() {
   for (Node<NamedNBT> node : this.node.getParent().getChildren()) {
     NBTBase base = node.getObject().getNBT();
     if (base != nbt && node.getObject().getName().equals(key.getText())) return false;
   }
   return true;
 }
Exemplo n.º 2
0
  public void initGUI(int x, int y) {
    this.x = x;
    this.y = y;

    section = new GuiCharacterButton((byte) 0, x + WIDTH - 1, y + 34);
    newLine = new GuiCharacterButton((byte) 1, x + WIDTH - 1, y + 50);
    String sKey = (key == null) ? node.getObject().getName() : key.getText();
    String sValue = (value == null) ? getValue(nbt) : value.getText();
    this.key = new GuiTextField(mc.fontRendererObj, x + 46, y + 18, 116, 15, false);
    this.value = new GuiTextField(mc.fontRendererObj, x + 46, y + 44, 116, 15, true);

    key.setText(sKey);
    key.setEnableBackgroundDrawing(false);
    key.func_82265_c(canEditText);
    value.setMaxStringLength(256);
    value.setText(sValue);
    value.setEnableBackgroundDrawing(false);
    value.func_82265_c(canEditValue);
    save = new GuiButton(1, x + 9, y + 62, 75, 20, "Save");
    if (!key.isFocused() && !value.isFocused()) {
      if (canEditText) key.setFocused(true);
      else if (canEditValue) value.setFocused(true);
    }
    section.setEnabled(value.isFocused());
    newLine.setEnabled(value.isFocused());
    cancel = new GuiButton(0, x + 93, y + 62, 75, 20, "Cancel");
  }
Exemplo n.º 3
0
 public GuiEditNBT(GuiNBTTree parent, Node<NamedNBT> node, boolean editText, boolean editValue) {
   this.parent = parent;
   this.node = node;
   this.nbt = node.getObject().getNBT();
   canEditText = editText;
   canEditValue = editValue;
 }
Exemplo n.º 4
0
  private static void setValidValue(Node<NamedNBT> node, String value) {
    NamedNBT named = node.getObject();
    NBTBase base = named.getNBT();

    if (base instanceof NBTTagByte) named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
    if (base instanceof NBTTagShort) named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
    if (base instanceof NBTTagInt) named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
    if (base instanceof NBTTagLong) named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
    if (base instanceof NBTTagFloat) named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
    if (base instanceof NBTTagDouble)
      named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
    if (base instanceof NBTTagByteArray)
      named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
    if (base instanceof NBTTagIntArray)
      named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
    if (base instanceof NBTTagString) named.setNBT(new NBTTagString(value));
  }
Exemplo n.º 5
0
 private void saveAndQuit() {
   if (canEditText) node.getObject().setName(key.getText());
   setValidValue(node, value.getText());
   parent.nodeEdited(node);
   parent.closeWindow();
 }