use of eu.pb4.sgui.api.gui.AnvilInputGui in project ArmorStandEditor by Patbox.
the class EditorGuis method openRenaming.
public static void openRenaming(ServerPlayerEntity player, Entity entity) {
ItemStack stack = Items.MAGMA_CREAM.getDefaultStack();
stack.setCustomName(new TranslatableText("armorstandeditor.gui.clearname").setStyle(Style.EMPTY.withItalic(false)));
ItemStack stack2 = Items.SLIME_BALL.getDefaultStack();
stack2.setCustomName(new TranslatableText("armorstandeditor.gui.setname").setStyle(Style.EMPTY.withItalic(false)));
AnvilInputGui gui = new AnvilInputGui(player, false) {
@Override
public void onInput(String input) {
super.onInput(input);
stack2.setCustomName(new TranslatableText("armorstandeditor.gui.setname", this.getInput()).setStyle(Style.EMPTY.withItalic(false)));
this.setSlot(2, stack2, (index, type, action) -> {
entity.setCustomName(new LiteralText(this.getInput()));
entity.setCustomNameVisible(true);
this.close(false);
});
}
};
gui.setTitle(new TranslatableText("armorstandeditor.gui.rename_title"));
gui.setDefaultInputValue(entity.getCustomName() != null ? entity.getCustomName().getString() : "");
gui.setSlot(1, stack, (index, type, action) -> {
entity.setCustomName(new LiteralText(""));
entity.setCustomNameVisible(false);
gui.close(false);
});
gui.setSlot(2, stack2, (index, type, action) -> {
entity.setCustomName(new LiteralText(gui.getInput()));
entity.setCustomNameVisible(true);
gui.close(false);
});
gui.open();
}
Aggregations